home *** CD-ROM | disk | FTP | other *** search
/ Apple II Magazines (PO) / Nibble Volume 09, No. 12 (1988-12)(MicroSPARC)(Side A).zip / Nibble Volume 09, No. 12 (1988-12)(MicroSPARC)(Side A).po / HRCOMP.T.txt < prev    next >
Text File  |  1996-12-24  |  6KB  |  200 lines

  1. **************************************************
  2. *                                                *
  3. *              HRCOMP Source Code                *
  4. *                                                *
  5. *             by S. Scott Zimmerman              *
  6. *              Copyright (c) 1988                *
  7. *              by MicroSPARC, Inc                *
  8. *              Concord, MA  01742                *
  9. *                                                *
  10. *           The MicroSPARC Assembler             *
  11. *                                                *
  12. **************************************************
  13.  
  14.  ORG $6000 ;Relocatable
  15.  
  16. **************************************************
  17. *  EQUates:                                      *
  18. **************************************************
  19.  
  20. ENDCOMP EQU $00 ;End addrs of compact
  21. COMPSTRT EQU $02 ;Start addrs of compact
  22. SCRNNUM EQU $06 ;0=HR pg 1; 32=HR pg 2
  23. LENGTH EQU $08 ;Length compact file
  24. SCREND EQU $19 ;Pntr last scrn byte+1
  25. HRPTR EQU $1C ;Pntr to HR screen
  26. COMPTR EQU $1E ;Pntr to compact pict
  27. ENDBYT EQU $80 ;#$80 ends 'on' bytes
  28. SCRN1 EQU $2000 ;HR pg 1 start
  29. MAXLEN EQU 5000 ;Max length allowed
  30. ENDSCRN EQU $3FF8 ;Last adrs of pg 1
  31.  
  32. **************************************************
  33. *  Define macros:                                *
  34. **************************************************
  35.  
  36. INCHR MAC ;Increment HR scrn byte
  37.  INC HRPTR ;Go to next HR byte
  38.  BNE ]A
  39.  INC HRPTR+1
  40. ]A LDA HRPTR ;Past HR screen?
  41.  CMP SCREND ;Compare LOB
  42.  LDA HRPTR+1 ;Get HOB for compare
  43.  SBC SCREND+1 ;End of 16-bit compare
  44.  BCS :A ;Branch to here
  45.  EMC
  46.  
  47. INCCO MAC ;Increment compact byte
  48.  INC COMPTR ;Go to next compact byte
  49.  BNE ]A
  50.  INC COMPTR+1
  51. ]A LDA COMPTR ;Past max length?
  52.  CMP ENDCOMP ;Compare LOB
  53.  LDA COMPTR+1 ;Get HOB for compare
  54.  SBC ENDCOMP+1 ;End of 16-bit compare
  55.  BCS :A ;Branch to here
  56.  EMC
  57.  
  58. **************************************************
  59. *  Initialize program pointers:                  *
  60. **************************************************
  61.  
  62.  LDA #SCRN1 ;Set scrn pntr address
  63.  STA HRPTR ;LOB
  64.  CLC ;Prepare to add
  65.  LDA #SCRN1/ ;HOB
  66.  ADC SCRNNUM ;Add 32 if HR page 2
  67.  STA HRPTR+1
  68.  LDA #ENDSCRN ;Set end pointer
  69.  STA SCREND ;LOB
  70.  CLC ;Prepare to add
  71.  LDA #ENDSCRN/ ;HOB
  72.  ADC SCRNNUM ;Add 32 if HR page 2
  73.  STA SCREND+1
  74.  CLC ;Prepare to add
  75.  LDA #MAXLEN ;Get maximum length
  76.  ADC COMPTR ;Add compact address
  77.  STA ENDCOMP ;Save as end of compact
  78.  LDA #MAXLEN/ ;HOB
  79.  ADC COMPTR+1
  80.  STA ENDCOMP+1 ;Save HOB
  81.  
  82.  LDA COMPTR ;Save compact address
  83.  STA COMPSTRT
  84.  LDA COMPTR+1
  85.  STA COMPSTRT+1
  86.  
  87. **************************************************
  88. *  Compact the Hi-Res picture:                   *
  89. **************************************************
  90.  
  91. GETBYT LDY #0 ;Zero the index
  92.  LDA (HRPTR),Y ;Get HR screen byte
  93.  BEQ NODOT ;Nothing there
  94.  CMP #ENDBYT ;Not 0, is it $80?
  95.  BEQ NODOT ;Yes, so treat as blank
  96.  PHA ;Save HR screen byte
  97.  LDA HRPTR ;Adrs of this byte
  98.  STA (COMPTR),Y ;Save in compact pict
  99.  INCCO TOOLONG1 ;Increment compact byte
  100.  LDA HRPTR+1 ;Get HOB curr HR addrs
  101.  SEC ;Prepare to subtract
  102.  SBC SCRNNUM ;Subtract 32 if HR pg 2
  103.  STA (COMPTR),Y ;Save HOB
  104.  INCCO TOOLONG1 ;Increment compact byte
  105.  PLA ;Restore screen byte
  106.  STA (COMPTR),Y ;Store byte value
  107.  INCCO TOOLONG1 ;Increment compact byte
  108.  INCHR STLEN1 ;Increment HR byte
  109.  CLV ;To force branch
  110.  BVC DOTON ;Always branch
  111. NODOT INCHR STLEN1 ;Increment HR byte
  112.  CLV ;To force branch
  113.  BVC GETBYT ;Always branch
  114.  
  115. **************************************************
  116. *  Relays (to avoid jumps for relocatability)    *
  117. **************************************************
  118.  
  119. TOOLONG1 CLV ;To force branch
  120.  BVC TOOLONG2 ;Always branch
  121. STLEN1 CLV  ;To force branch
  122.  BVC STLEN ;Always branch
  123. GETBYT1 CLV ;To force branch
  124.  BVC GETBYT ;Always branch
  125.  
  126. **************************************************
  127. *  Check if next 4 bytes are zero:               *
  128. **************************************************
  129.  
  130. DOTON LDA (HRPTR),Y ;Get HR byte
  131.  INY ;Go to next HR byte
  132.  ORA (HRPTR),Y ;OR it with previous
  133.  INY ;Go to next HR byte
  134.  ORA (HRPTR),Y ;Or it with previous
  135.  INY ;Got to next HR byte
  136.  ORA (HRPTR),Y ;Or this also
  137.  BEQ CLEAR ;All are clear
  138.  CMP #ENDBYT ;Also check for $80
  139.  BEQ CLEAR ;No pixel on either
  140.  LDY #0 ;Go back to orig byte
  141.  LDA (HRPTR),Y ;Get it again
  142.  CMP #ENDBYT ;Is it $80?
  143.  BNE ADDON ;No, so add to table
  144.  LDA #0 ;Yes, convert to 0
  145. ADDON STA (COMPTR),Y ;Save byte in compact
  146.  INCCO TOOLONG1 ;Increment compact
  147.  INCHR STLEN ;Increment HR byte
  148.  CLV ;To force branch
  149.  BVC DOTON ;Always branch
  150. CLEAR LDY #0 ;Set index back to 0
  151.  LDA #ENDBYT ;Get end byte $80
  152.  STA (COMPTR),Y ; Store in table
  153.  INCCO TOOLONG ;Increment compact
  154.  INCHR STLEN ;Increment HR byte
  155.  CLV ;To force branch
  156.  BVC GETBYT1 ;Always branch
  157.  
  158. TOOLONG2 CLV ;Relay (relocatability)
  159.  BVC TOOLONG
  160.  
  161. **************************************************
  162. *  Calculate length of compact picture:          *
  163. **************************************************
  164.  
  165. STLEN SEC ;Prepare to subtract
  166.  LDA COMPTR ;Get current (end) adrs
  167.  SBC COMPSTRT ;Subtract starting adrs
  168.  STA LENGTH ;Save length LOB
  169.  LDA COMPTR+1 ;Do HOB
  170.  SBC COMPSTRT+1
  171.  STA LENGTH+1
  172.  LDA SCRNNUM ;Restore scrn number
  173.  STA HRPTR
  174.  
  175.  LDY #0 ;Put three $80 at end
  176.  LDA #ENDBYT
  177.  STA (COMPTR),Y
  178.  INY
  179.  STA (COMPTR),Y
  180.  INY
  181.  STA (COMPTR),Y
  182.  
  183.  LDA LENGTH ;Check if zero
  184.  ORA LENGTH+1
  185.  BNE ADD3 ;No, so add 3
  186.  RTS ;Yes, so end here
  187. ADD3 CLC ;Add these 3 to length
  188.  LDA LENGTH
  189.  ADC #3
  190.  STA LENGTH
  191.  LDA LENGTH+1
  192.  ADC #0
  193.  STA LENGTH+1
  194. QUIT RTS ;Done
  195.  
  196. TOOLONG LDA #0 ;Set length to 0...
  197.  STA LENGTH ; if compact picture
  198.  STA LENGTH+1 ; is too long
  199.  RTS ;Abort
  200.